import request from '@/config/axios'

// 用户-班级 VO
export interface UserClassVO {
  id: number // 主键
  name: string // 班级名称
  userId: number // 持有者
  teacher: string // 持有者名称
  maxMemCount: number // 成员人数上限
  memCount: number // 已加入成员
  expireTime: Date // 过期时间
  source: string // 班级来源
  code: string // 班级码
}

// 用户-班级 API
export const UserClassApi = {
  // 查询用户-班级分页
  getUserClassPage: async (params: any) => {
    return await request.get({ url: `/exam/user-class/page`, params })
  },

  // 查询用户-班级详情
  getUserClass: async (id: number) => {
    return await request.get({ url: `/exam/user-class/get?id=` + id })
  },

  // 新增用户-班级
  createUserClass: async (data: UserClassVO) => {
    return await request.post({ url: `/exam/user-class/create`, data })
  },

  // 修改用户-班级
  updateUserClass: async (data: UserClassVO) => {
    return await request.put({ url: `/exam/user-class/update`, data })
  },

  // 完善用户-班级
  fillUserClass: async (data: UserClassVO) => {
    return await request.post({ url: `/exam/user-class/member/fill`, data })
  },

  // 新增 用户-班级
  addUserClass: async (data: UserClassVO) => {
    return await request.post({ url: `/exam/user-class/member/create`, data })
  },

  // 删除用户-班级
  deleteUserClass: async (id: number) => {
    return await request.delete({ url: `/exam/user-class/delete?id=` + id })
  },

  // 导出用户-班级 Excel
  exportUserClass: async (params) => {
    return await request.download({ url: `/exam/user-class/export-excel`, params })
  },
  // 获得用户-班级-成员分页
  checkUserClassFree: async () => {
    return await request.get({ url: `/exam/user-class/member/check-free`})
  },
// ==================== 子表（用户-班级-成员） ====================

  // 获得用户-班级-成员分页
  getUserClassMemPage: async (params) => {
    return await request.get({ url: `/exam/user-class/user-class-mem/page`, params })
  },
  // 新增用户-班级-成员
  createUserClassMem: async (data) => {
    return await request.post({ url: `/exam/user-class/user-class-mem/create`, data })
  },

  // 修改用户-班级-成员
  updateUserClassMem: async (data) => {
    return await request.put({ url: `/exam/user-class/user-class-mem/update`, data })
  },

  // 删除用户-班级-成员
  deleteUserClassMem: async (id: number) => {
    return await request.delete({ url: `/exam/user-class/user-class-mem/delete?id=` + id })
  },

  // 获得用户-班级-成员
  getUserClassMem: async (id: number) => {
    return await request.get({ url: `/exam/user-class/user-class-mem/get?id=` + id })
  },

// ==================== 子表（用户-班级-记录） ====================

  // 获得用户-班级-记录分页
  getUserClassRecordPage: async (params) => {
    return await request.get({ url: `/exam/user-class/user-class-record/page`, params })
  },
  // 新增用户-班级-记录
  createUserClassRecord: async (data) => {
    return await request.post({ url: `/exam/user-class/user-class-record/create`, data })
  },

  // 修改用户-班级-记录
  updateUserClassRecord: async (data) => {
    return await request.put({ url: `/exam/user-class/user-class-record/update`, data })
  },

  // 删除用户-班级-记录
  deleteUserClassRecord: async (id: number) => {
    return await request.delete({ url: `/exam/user-class/user-class-record/delete?id=` + id })
  },

  // 获得用户-班级-记录
  getUserClassRecord: async (id: number) => {
    return await request.get({ url: `/exam/user-class/user-class-record/get?id=` + id })
  }
}
